﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Gqq.Csharpindepth.DataStructure
{
   public class BinarySearchClass
    {
       public static int BinarySearch(int[] arr,int start,int end, int a)
       {
           //传入的参数是否正确
           if (start > end)
               return -1;
           var mid = (start + end)/2;
           if (arr[mid] == a)
               return mid;
           if (arr[mid] > a)
               return BinarySearch(arr, start, mid - 1, a);
           return BinarySearch(arr, mid + 1, end, a);
       }
    }
}
